import requests
import lxml.etree as le

url = 'https://www.runoob.com/html/html-tutorial.html'
x = '//div[@id="leftcolumn"]/a/text()'
content = requests.get(url).content
contentx = le.HTML(content)
rets = contentx.xpath(x)

df_fold = pd.DataFrame(
columns={'level1'}
)
level1s = []


for levels,groupby_levels in df_unfold.groupby(['level1']):

    level1s.append(levels[0])

    df_fold['level1'] = level1s


writer = pd.ExcelWriter('category.xlsx')
df_fold.to_excel(writer,sheet_name='分类')
writer.save()